<!--{include(file='head.html')}-->

<div id="wrap">
	<!--{include('left.html')}-->
	<div id="maincont">
		<b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b>
		<div id="main_c" >
			<form name="seaform" id="seaform" action="" method="post">
				<div class="bt_bk">
					<span class="btn">
						<a href="javascript:void(0);" onclick="$.oper.refresh();return false;">刷新</a>
						<a href="javascript:void(0);" onclick="$.oper.remove();return false;">移除</a>
						<a href="<!--{url('admin','cat','catadd')}-->">添加</a>
					</span>
					<span class="state_tip"></span>
				</div>
			</form>
			
			<table class="tableStyle" border="0" cellspacing="0" cellpadding="0">
				<thead>
					<tr align="center">
						<th width="5%">
							<input type="checkbox" value="1" name="allselect" id="allselect" autocomplete="off" onclick="$.oper.selectall()"/>
						</th>
						<th width="20%">操作</th>
						<th width="35%">分类名称</th>
						<th width="20%">商品类型</th>
						<th width="20%">排序</th>
					</tr>
				</thead>
				<tbody id="listtbody">
					<!--{foreach $listcat cat}-->
					<tr align="center" id="tr_<!--{$cat.catid}-->" class="level<!--{$cat.level}-->">
						<td><input type="checkbox" value="<!--{$cat.catid}-->" name="singleselect" autocomplete="off"/></td>
						<td>
							<a href="<!--{url('admin','cat','catedit','catid=$cat.catid')}-->" class="edit"></a>
							<a href="javascript:void(0);" onclick="$.oper.remove(<!--{$cat.catid}-->);return false;" class="remove"></a>
						</td>
						<td align="left">
							<span class="catlevel" style="padding-left:<!--{$cat.level * 20}-->px"></span>
							<img src="template/admin/images/minus.gif" width="9" height="9" class="level<!--{$cat.level}-->" id="<!--{$cat.catid}-->_<!--{$cat.level}-->" onclick="$.oper.toggle(this)"/>
							<span onclick="$.oper.edit(this,'catname','<!--{$cat.catid}-->')" title="点击修改分类名称" onmouseover="$.oper.bgcolor(this,'on')" onmouseout="$.oper.bgcolor(this,'off')"><!--{$cat.catname}--></span>
						</td>
						<td>
							<!--{def($types[$cat[typeid]],'--')}-->
						</td>
						<td>
							<span style="padding-left:<!--{$cat.level * 30}-->px">&nbsp;</span>
							<span onclick="$.oper.edit(this,'order','<!--{$cat.catid}-->')" title="点击修改分类排序" onmouseover="$.oper.bgcolor(this,'on')" onmouseout="$.oper.bgcolor(this,'off')"><!--{$cat.order}--></span>
						</td>
						
					</tr>
					<!--{/foreach}-->
				</tbody>
			</table>
		</div>
		<b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b>
	</div>
</div>
<!--{include(file='foot.html')}-->
<script type="text/javascript">
$(function(){
	$.oper.init("<!--{url('admin','cat','catsave')}-->");
	$.oper.toggle = function(obj) {
		var $this = $(obj),
			level = parseInt($this.attr("class").replace("level","")) || 0,
			$next = $this.parents("tr").nextAll("tr"),
			func;
		if($this.attr("src").indexOf("minus") !== -1) {
			$this.attr("src","template/admin/images/plus.gif");
			func = "hide";
		} else {
			$this.attr("src","template/admin/images/minus.gif");
			func = "show";
		}
		$next.each(function() {
			var $ele = $(this),
				$img = $ele.find("img"),
				thelevel = parseInt( $img.attr("class").replace("level","") ) || 0;
			if(thelevel > level) {
				$ele[func]();
			} else {
				return false;
			}
		});
	}
});
</script>